package com.coin900.coin.service.sop;

import com.coin900.coin.persist.sop.SopMenuVO;
import com.coin900.coin.persist.sop.SopRoleMenuVO;
import com.value.mybatis.IDaoRouter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author shui
 * @create 2018-01-05
 **/
@Service
public class SopRoleMenuService implements ISopRoleMenuService {

    @Override
    public List<SopRoleMenuVO> loadSopRoleMenu(Map<String, Object> params) {
        return this.daoRouter.query("SopRoleMenu.loadSopRoleMenu", params);
    }

    @Override
    public void insertSopRoleMenu(SopRoleMenuVO sopRoleMenuVO) {
        this.daoRouter.insert("SopRoleMenu.insertSopRoleMenu", sopRoleMenuVO);
    }

    @Override
    public void insertSopRoleMenuBatch(Long roleId, List<SopMenuVO> sopMenuList) {
        for (SopMenuVO sopMenuVO : sopMenuList) {
            SopRoleMenuVO sopRoleMenuVO = new SopRoleMenuVO();
            sopRoleMenuVO.setRoleId(roleId);
            sopRoleMenuVO.setMenuId(sopMenuVO.getId());
            this.daoRouter.insert("SopRoleMenu.insertSopRoleMenu", sopRoleMenuVO);
        }
    }

    @Override
    public void updateSopRoleMenu(SopRoleMenuVO sopRoleMenuVO) {
        this.daoRouter.update("SopRoleMenu.updateSopRoleMenu", sopRoleMenuVO);
    }

    @Override
    public void deleteSopRoleMenu(SopRoleMenuVO sopRoleMenuVO) {
        this.daoRouter.update("SopRoleMenu.deleteSopRoleMenu", sopRoleMenuVO);
    }

    @Autowired
    private IDaoRouter daoRouter;

}